package com.yjha.lzmarathonsys.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.yjha.lzmarathonsys.dto.Param;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.yjha.lzmarathonsys.bean.TbPersonClockin;
import com.yjha.lzmarathonsys.service.TbPersonClockinService;
import com.yjha.lzmarathonsys.utils.PageUtils;
import com.yjha.lzmarathonsys.utils.R;
import org.springframework.web.multipart.MultipartFile;


/**
 * 个人打卡表
 *
 * @author æ­å°
 * @email 1971240051@qq.com
 * @date 2025-05-13 15:07:07
 */
@Api(tags = "个人打卡表")
@RestController
@RequestMapping("lzmarathonsys/tbpersonclockin")
// @CrossOrigin
public class TbPersonClockinController {
    @Autowired
    private TbPersonClockinService tbPersonClockinService;

    /**
     * 列表
     */
    @PostMapping("/list")
    @ApiOperation("个人打卡表列表")
    //@RequiresPermissions("lzmarathonsys:tbpersonclockin:list")
    public R list(@RequestBody Param params){
        PageUtils page = tbPersonClockinService.queryPage(params);

        return R.ok().put("page", page);
    }

    @PostMapping("/UnderList")
    @ApiOperation("个人打卡待审核列表")
    //@RequiresPermissions("lzmarathonsys:tbpersonclockin:list")
    public R UnderList(@RequestBody Param params){
        PageUtils page = tbPersonClockinService.UnderList(params);

        return R.ok().put("page", page);
    }

    /**
     * 列表
     */
    @PostMapping("/getAll")
    @ApiOperation("个人打卡所有列表")
    //@RequiresPermissions("lzmarathonsys:tbpersonclockin:list")
    public R getAll(@RequestBody Param params){
        R r = tbPersonClockinService.getAll(params);

        return r;
    }


    /**
     * 信息
     */
    @GetMapping("/info/{tbId}")
    @ApiOperation("个人打卡表信息")
    //@RequiresPermissions("lzmarathonsys:tbpersonclockin:info")
    public R info(@PathVariable("tbId") Integer tbId){
		R r = tbPersonClockinService.getTbPersonClockinById(tbId);

        return r;
    }

    /**
     * 获取经纬度的人员
     * @param tbId
     * @return
     */
    @GetMapping("/getLongitude")
    @ApiOperation("获取经纬度以及打卡数量")
    //@RequiresPermissions("lzmarathonsys:tbpersonclockin:info")
    public R getLongitude(){//@RequestBody List<String> longitudeLatitude){
        R r = tbPersonClockinService.getLongitude();//longitudeLatitude);

        return r;
    }

    // /**
    //  * 获取经纬度的人员
    //  * @param tbId
    //  * @return
    //  */
    // @GetMapping("/getLongitudeData")
    // @ApiOperation("经纬度获取打卡信息数据")
    // //@RequiresPermissions("lzmarathonsys:tbpersonclockin:info")
    // public R getLongitudeData(@RequestBody List<String> longitudeLatitude){
    //     R r = tbPersonClockinService.getLongitudeData(longitudeLatitude);
    //
    //     return r;
    // }

    /**
     * 我的打卡列表
     */
    @PostMapping("/myClockin")
    @ApiOperation("我的个人打卡记录")
    //@RequiresPermissions("lzmarathonsys:tbpersonclockin:info")
    public R myClockin(@RequestBody Param params){
        R r = tbPersonClockinService.getmyClockinById(params);

        return r;
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation("个人打卡表保存")
    //@RequiresPermissions("lzmarathonsys:tbpersonclockin:save")
    public R save(@RequestPart("tbPersonClockin") TbPersonClockin tbPersonClockin, @RequestPart("files") MultipartFile[] files) throws Exception{
		R r = tbPersonClockinService.saveTbPersonClockin(tbPersonClockin, files);

        return r;
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation("个人打卡表修改")
    //@RequiresPermissions("lzmarathonsys:tbpersonclockin:update")
    public R update(@RequestBody TbPersonClockin tbPersonClockin){
		tbPersonClockinService.updateById(tbPersonClockin);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    @ApiOperation("个人打卡表删除")
    //@RequiresPermissions("lzmarathonsys:tbpersonclockin:delete")
    public R delete(@RequestBody Integer[] tbIds){
		tbPersonClockinService.removetbPersonClockinByIds(Arrays.asList(tbIds));

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/audit")
    @ApiOperation("个人打卡表审核")
    //@RequiresPermissions("lzmarathonsys:tbpersonclockin:delete")
    public R audit(@RequestBody TbPersonClockin tbPersonClockin){
        tbPersonClockinService.audit(tbPersonClockin);

        return R.ok();
    }

}
